package com.singzi.leetcode.N200;

import java.util.Arrays;

public class T0128 {
    public static void main(String[] args) {
        int []nums = {0,3,7,2,5,8,4,6,0,1};
        Solution0128 solution0128 = new Solution0128();
        System.out.println(solution0128.longestConsecutive(nums));

    }
}
class Solution0128 {
    public int longestConsecutive(int[] nums) {

        Arrays.sort(nums);
        int max = 1;
        int cnt = 1;
        for(int i = 1;i < nums.length;i++){
            if(nums[i] == nums[i-1]) continue;
            else if(nums[i] - nums[i-1] > 1){
                if(cnt > max){
                    max = cnt;
                }
                cnt = 1;
                // i++;
            }
            else{
                cnt++;
            }
        }
        return max;

    }
}